package com.soft863.tc.analysis.reducer;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/*
 * 分析数据Reducer
 * */
public class AnalysisTextReducer extends Reducer<Text, Text, Text, Text> {
    private final Text v = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        int sumCall = 0;
        int sumDuration = 0;
        for (Text value : values) {
            sumCall += 1;
            sumDuration += Integer.parseInt(value.toString());
        }
        v.set(sumCall + "_" + sumDuration);
        context.write(key, v);
    }
}
